﻿CREATE VIEW dbo.View_2
AS
SELECT        TOP (100) PERCENT dbo.DefinedAttributes.AttributeName, dbo.Attributes.AttributeValueString, dbo.Attributes.EntityID, dbo.Entities.EntityType, dbo.Entities.EntitySubType, dbo.Entities.EntityName
FROM            dbo.Attributes INNER JOIN
                         dbo.Entities ON dbo.Attributes.EntityID = dbo.Entities.EntityID INNER JOIN
                         dbo.DefinedAttributes ON dbo.Attributes.AttributeID = dbo.DefinedAttributes.AttributeID
WHERE        (dbo.Attributes.AttributeValueString IS NOT NULL) AND (dbo.Entities.EntityType = N'Person') AND (dbo.Attributes.AttributeValueString <> '')
ORDER BY dbo.Attributes.AttributeValueString